Skip to content

DOC added example to reorder levels #43134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed

DOC added example to reorder levels #43134

wants to merge 3 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Aug 20, 2021

Added an example for reorder levels.

@pep8speaks
Copy link

pep8speaks commented Aug 20, 2021

Hello @Nikhil636! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 6840:1: W293 blank line contains whitespace
Line 6846:42: W291 trailing whitespace
Line 6851:1: W293 blank line contains whitespace
Line 6851:9: E101 indentation contains mixed spaces and tabs
Line 6851:9: W191 indentation contains tabs
Line 6853:26: W291 trailing whitespace
Line 6857:1: W293 blank line contains whitespace
Line 6859:1: W293 blank line contains whitespace
Line 6861:26: W291 trailing whitespace
Line 6865:1: W293 blank line contains whitespace

Comment last updated at 2021-08-21 07:19:08 UTC

@jreback jreback added Docs Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Aug 21, 2021
@jreback jreback added this to the 1.4 milestone Aug 21, 2021
--------
>>> df = pd.DataFrame(
... {"name" : ['Rahul','Arijit']},
... index = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you name the levels? will be much more obvious what is happening.

90 CSE A Rahul
77 EEE B Arijit

>>> df.reorder_levels([0,2,1])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use spaces between then numbers (pep)

you can see if you can enable the doc-string test for this

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the example. Please review it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you haven't put spaces between the numbers, please check https://www.python.org/dev/peps/pep-0008/

... 'Grade':['C', 'B', 'A'],
... }
>>> df=pd.DataFrame(data, columns = ['Mark', 'Branch', 'Grade', 'Name'])
>>> df.set_index(['Branch', 'Mark', 'Grade'], inplace = True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, can you please write this as df = df.set_index(['Branch', 'Mark', 'Grade'])?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I will do the changes.

@MarcoGorelli
Copy link
Member

MarcoGorelli commented Aug 22, 2021

Actually, #42935 was already open for this issue, and it looks like it's still active - let's close in favour of that one for now

Next time, please check that there's not already an open PR, that one was linked in the issue

EDIT

This PR was a blatant attempt at plagiarising #42935

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants